Questions
2 of 15
1What are the main categories of data types available in MySQL?
2What is the difference between CHAR and VARCHAR data types?
3Which data type would you use to store dates and times in MySQL?
4What is the difference between INT, FLOAT, and DECIMAL data types?
5What is the use of the TEXT and BLOB data types, and how are they different from VARCHAR?
6How does MySQL handle precision and scale in DECIMAL(M, D) columns internally, and how do these differ from FLOAT and DOUBLE in terms of storage and accuracy?
7When storing time zone–aware data, what are the differences in behavior and use cases between DATETIME, TIMESTAMP, and CONVERT_TZ() in MySQL?
8If you define a VARCHAR(255) column with utf8mb4 encoding, how does MySQL calculate the maximum possible storage size for that column, and how does it differ from CHAR(255)?
9What are the advantages and limitations of using ENUM and SET data types in terms of performance, flexibility, and schema evolution?
10Explain how MySQL internally stores and sorts values of type BLOB and TEXT. What happens when you try to index a TEXT column?
11How do signed and unsigned integer types affect query results, index usage, and storage size? Can you demonstrate an example where overflow behavior differs?
12In what scenarios would using a JSON column be preferable to a normalized table structure, and what are the internal storage and indexing implications of JSON in MySQL 8.0?
13How does MySQL’s BIT(M) type differ from BOOLEAN, TINYINT(1), and binary string types (BINARY, VARBINARY) in terms of storage, representation, and retrieval?
14If you define a composite index on multiple columns of different data types (e.g., INT, VARCHAR, and DATE), how do the internal data type differences influence sorting, comparisons, and index efficiency?
15What are the practical implications of using CHAR vs VARCHAR for columns in InnoDB tables with varying row lengths and frequent updates? How does this choice affect row fragmentation and performance?
02 / 15

What is the difference between CHAR and VARCHAR data types?

Difference Between CHAR and VARCHAR

CHAR and VARCHAR are both string data types in MySQL, but they differ in how they store data and manage memory.

Key Differences
  1. 1

    CHAR is a fixed-length data type, while VARCHAR is a variable-length data type.

  2. 2

    CHAR pads unused space with spaces, whereas VARCHAR stores only the actual characters.

  3. 3

    CHAR is faster for fixed-length data because of predictable storage size.

  4. 4

    VARCHAR is more space-efficient for variable-length data.

  5. 5

    CHAR can store up to 255 characters, while VARCHAR can store up to 65,535 characters (depending on row size).

Difficulty: 3/10
Topics: storage efficiency, padding behavior, index performance

Scenario Questions

0-2 years experience
  1. 1

    You're building a user signup form where country codes are always 2 letters — should you use CHAR(2) or VARCHAR(2)? Why?

  2. 2

    A junior dev used CHAR(255) for email addresses and says it's 'faster'. How would you explain why that's a bad idea?

  3. 3

    What happens if you store 'John' in a CHAR(10) column and then query for 'John' with WHERE column = 'John'? Does it match?

2-5 years experience
  1. 1

    Our user bio field was defined as CHAR(500) and now our database is 30% larger than expected — what’s likely the root cause and how would you fix it without downtime?

  2. 2

    We noticed slow queries on a table with a VARCHAR(255) indexed column — could the data type be part of the problem? What would you check?

  3. 3

    A legacy table uses CHAR for product SKUs that vary from 6 to 12 characters. We’re seeing inconsistent search results — what might be going wrong?

5-8 years experience
  1. 1

    We’re migrating a high-write OLTP system from CHAR to VARCHAR for 50M rows — what performance, locking, and index rebuild risks do you anticipate, and how would you mitigate them?

  2. 2

    Our analytics team complains that GROUP BY on a CHAR(50) column is 2x faster than on VARCHAR(50), even though data is mostly 10-15 chars. How do you explain this and would you change it?

  3. 3

    In a sharded database, we’re seeing uneven storage usage across shards due to mixed CHAR/VARCHAR usage. How would you audit and standardize this at scale?

8+ years experience
  1. 1

    We’re designing a global audit log system that must support 10TB/year of metadata — some fields are fixed (e.g., status codes), others are variable (e.g., error details). How do you decide between CHAR and VARCHAR at the schema level, and what long-term operational costs do you weigh?

  2. 2

    A legacy system uses CHAR for all string fields to 'ensure consistency' — we want to modernize but fear breaking downstream ETLs and reporting tools. How do you plan and justify a migration strategy across teams?

  3. 3

    Our data warehouse team insists on using CHAR for all dimensions to simplify joins, but our OLTP team says it’s bloating storage. As an architect, how do you resolve this cross-team conflict and design a unified strategy?

Follow-up Questions

  • What happens if you insert a 20-character string into a CHAR(10) column?
  • How does padding affect string comparisons in CHAR vs VARCHAR?
  • When might you still choose CHAR over VARCHAR despite the space cost?